package com.ruoyi.web.core.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.io.File;
import java.io.IOException;

@Data
@Component
public class ConfigLoader {
    @Value("${info.rm.path}")
    private String rmPath;
    @Value("${info.gamenames.path}")
    private String gamenamesPath;
    private static Config config;

    @PostConstruct
    public void init() throws IOException {
        ObjectMapper objectMapper = new ObjectMapper();
        config = objectMapper.readValue(new File(gamenamesPath + "config.json"), Config.class);
    }

    public static Config getConfig() {
        return config;
    }

    @Data
    public static class Config {
        private String obHost;
        private String rmHost;
        private String jybHost;
        private String ktHost;
        private String hcHost;
        private String httpHostJd;
        private String httpHostHwy;
        private String httpHostZyt;
        private String httpHostHg;
        private String kjwHost;
        private String leyuHost;
        private String aqHost;
    }
}
